import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
Vue.directive('fixing', {
  inserted(el) {
    el.src = el.src || require('@/assets/common/head.jpg')
    el.addEventListener('error', () => {
      el.src = require('@/assets/common/head.jpg')
    })
  }
})

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
import plugins from '@/components/plugins/plugins'
Vue.use(plugins)

// 创建过滤器
Vue.filter('formDate', (oldVal) => {
  // return oldVal.split('T')[0]
  return /T/.test(oldVal) ? oldVal.split('T')[0] : oldVal
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
